-
Notifications
You must be signed in to change notification settings - Fork 94
Add tokenpath parameter to collector #1077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
internal/config/config_test.go
Outdated
//go:embed testdata/nginx-agent-with-token.conf | ||
var agentConfigWithToken string | ||
|
||
func getAgentConfigWithToken(token string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be moved to /agent/test/config/nginx_config.go
internal/config/config.go
Outdated
@@ -871,6 +871,7 @@ func processOtlpReceivers(tlsConfig *OtlpTLSConfig) error { | |||
func resolveExtensions() Extensions { | |||
var health *Health | |||
var headersSetter *HeadersSetter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a new FilePath field to the Header struct instead of putting file paths in the Value field.
internal/config/config.go
Outdated
if headersSetter != nil { | ||
token, err := getToken(headersSetter) | ||
if err != nil { | ||
slog.Error("error getting token from config", "error", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slog.Error("error getting token from config", "error", err) | |
slog.Error("Unable to get token from collector headers setter config", "error", err) |
internal/config/config.go
Outdated
func getToken(headersSetter *HeadersSetter) (string, error) { | ||
var err error | ||
|
||
token := headersSetter.Headers[0].Value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to handle the case where there are more than one header so you will need to loop through the list and check the Value and FilePath for each one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are multiple, which one do we use?
internal/config/config.go
Outdated
return Extensions{ | ||
Health: health, | ||
HeadersSetter: headersSetter, | ||
} | ||
} | ||
|
||
func values(headers []Header) []Header { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename the function to something like updateHeaders
?
Proposed changes
header-setter
parameter of the agent configresolveExtensions
methodChecklist
Before creating a PR, run through this checklist and mark each as complete.
CONTRIBUTING
documentmake install-tools
and have attached any dependency changes to this pull requestREADME.md
)